#include "comm.hpp"
#include <iostream>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main()
{
    //打开管道文件
    int fd = open(FIFO_FILE, O_WRONLY);
    if(fd < 0)
    {
        std::cerr << "open" << std::endl;
        return 1;
    }

    //写入信息
    std::string msg;
    while(true)
    {
        std::cout << "Pleace input:";
        std::getline(std::cin, msg);
        msg += "[" + std::to_string(getpid()) + "]";
        write(fd, msg.c_str(), msg.size());
    }

    //关闭管道文件
    close(fd);
    return 0;
}